Conversation
Adds Codex CLI as the fourth supported backend, plus shell-write detection in the Bash hook (motivated by Codex GPT models' atomic- replace idiom) and an ApplyPatch delete-icon fix that surfaced while testing Codex's `*** Delete File:` directives. - Codex backend: `.codex/hooks.json` install + `codex_hooks` feature- flag detection (project + global), surfaced in :CodePreviewStatus and :checkhealth. - Shell-write detection: `>` / `>>` / `&>` / `&>>`, `mv X.tmp X`, `cp`, `tee`, `sed -i` targets are flagged in the changes registry as bash_modified / bash_created so neo-tree shows feedback for shell- driven edits during the approval window. - ApplyPatch delete: show_diff accepts an action hint; deletes now render the red trash icon, with no false positives for legitimate truncate-to-empty edits. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The blanket /tmp/* rule masked real shell-write targets on Linux, where mktemp paths stay under /tmp (macOS resolves /tmp to /private/tmp via pwd -P, so the filter happened to miss). Transience is signaled by the extension or /dev/*, not by being under /tmp. Fixes Ubuntu CI failures in tests/backends/codex/test_edit.sh: - Codex Bash shell write marks existing file modified - Codex Bash atomic-replace idiom marks real target - Codex Bash shell write marks new file created - Codex Bash filters HTML-comment false positives Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Without `approval_policy = "on-request"` and `sandbox_mode = "read-only"` in config.toml, Codex applies edits without prompting and the diff preview never blocks on the user's decision — defeating the point of the workflow. Bundle both alongside the existing `codex_hooks` flag in the Quick Start. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.codex/hooks.jsonand detects the requiredcodex_hooks = truefeature flag in.codex/config.toml(project or global) —:CodePreviewStatusand:checkhealthboth surface flag state so users can self-diagnose silent-no-op failures.>/>>/&>/&>>,mv X.tmp X,cp,tee, andsed -itargets are flagged in the changes registry asbash_modified/bash_createdso users get neo-tree feedback for shell-driven edits — important for Codex GPT models, which prefer the atomic-replace idiom ({ printf …; cat F; } > F.tmp && mv F.tmp F).*** Delete File:showing the orange "modified" pencil instead of the red "deleted" trash icon.What's included
Codex backend
backends/codex/{code-preview-diff,code-close-diff}.sh— translate Codex's payload (which deliversapply_patchtext intool_input.command) into the normalized shape consumed bybin/core-{pre,post}-tool.sh.Bashpasses through.lua/code-preview/backends/codex.lua— install/uninstall, plusfeature_flag_state()that checks.codex/config.toml(project) and falls back to~/.codex/config.toml(global).:CodePreviewInstall/UninstallCodexCliHookscommands; Codex rows in:CodePreviewStatusand:checkhealth, including feature-flag detection.Shell-write detection (Bash hook)
bin/core-pre-tool.shthat extracts likely write targets from a Bash command and marks each onebash_modified(file exists) orbash_created(file doesn't exist) in the changes registry.looks_like_pathfilters false positives leaked from quoted strings (e.g.printf '<!-- … -->\n\n');is_transient_pathskips.tmp/.bak/.swp//dev/*//tmp/*; tilde paths expand to$HOMEbefore the relative-path resolver to avoid$CWD/~/foo.rms and writes, only the rm branch queues adefer_fnreveal so we don't double-fire.mv -t DSTflag-inverted form,tee FILE OTHER_FILEmulti-target, and the always-on cost of the detector for read-only Bash invocations.Neo-tree integration for shell writes
bash_modifiedandbash_createdrender with the same icons/highlights asmodifiedandcreatedfor v1 — documented inneo_tree.luaas a deliberate simplification.changes.clear_by_statuses({...})helper; the Bash post-hook now batchesdeleted+bash_modified+bash_createdcleanup into a single RPC instead of three.ApplyPatch delete fix
show_diffaccepts an optionalactionhint; the Codex/ApplyPatch hook passes"delete"for*** Delete File:directives.mark_change_and_revealonly emits"deleted"when explicitly told — a legitimate truncate-to-empty edit still shows asmodified.vim.loop.fs_statswitched tovim.uv.fs_statindiff.luato match the convention used elsewhere in the codebase.Docs / housekeeping
>= 0.10(matches actualvim.uvusage),:checkhealthwording, test-runner examples forbackends/copilotandbackends/codex..gitignore: ignoretest_output.log.Tests
22 new shell tests in the Codex suite plus 2 plenary regressions:
tests/backends/codex/test_install.sh—.codex/hooks.jsonlayout, idempotent re-install, user-authored Pre/PostToolUse entries survive install/uninstall, feature-flag detection (project + global, missing flag, no config.toml).tests/backends/codex/test_edit.sh— Codexapply_patchtranslation, Bashrm, shell-write detection (modified/created/atomic-replace/.tmp filter), HTML-comment false-positive guard, read-only no-op, noise-tool skip, malformed-payload skip.tests/backends/codex/test_apply_patch.sh— Update / Add / mixed Update+Add+Delete.tests/plugin/diff_lifecycle_spec.lua—show_diff(..., "delete")marks the filedeleted; truncate-to-empty without an action staysmodified(regression guard against the false-positive that the action hint replaced).test_install_preserves_user_hooksextended to assert PostToolUse mirroring (was previously only checking PreToolUse).Test plan
bash tests/run.sh allpasses locally./tests/run_lua.sh diff_lifecycle— plenary regressions passcodex_hooks = true:CodePreviewStatusand:checkhealth code-previewcorrectly report flag state for: project config, global config (~/.codex/config.toml), missing flag, no config fileapply_patchUpdate / Add / Delete — diffs open on pre, close on accept,*** Delete File:shows the red trash icon in neo-tree{ … } > F.tmp && mv F.tmp F) — neo-tree shows the orange pencil onFduring the approval window, clears on post